﻿<Window x:Class="Rosd.Wpf.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:scm="clr-namespace:System.ComponentModel;assembly=WindowsBase"
        xmlns:local="clr-namespace:Rosd.Wpf"
        xmlns:vm="clr-namespace:Rosd.Wpf.ViewModels"
        d:DataContext="{d:DesignInstance Type=vm:TrackViewModel}"
        mc:Ignorable="d"
        Title="Реестр документов" Height="450" Width="800" Loaded="Window_Loaded">
    <Window.DataContext>
        <vm:TrackViewModel/>
    </Window.DataContext>
    <Grid>
        <TabControl x:Name="tabControl">
            <TabItem Name="inBox">
                <TabItem.Header>
                    <StackPanel Orientation="Horizontal">
                        <TextBlock Text="Конверты"/>
                    </StackPanel>
                </TabItem.Header>
                <TabItem.Content>
                    <DockPanel>
                        <GroupBox DockPanel.Dock="Bottom" Header="Конверт" Height="Auto">
                            <DockPanel>
                                <StackPanel DockPanel.Dock="Right" Orientation="Vertical">
                                    <Button Content="Save" Command="{Binding SaveCommand}"/>
                                    <Button Content="Cancel" Command="{Binding ResetCommand}"/>
                                </StackPanel>
                                <Grid Margin="0,0,10,10">
                                    <Grid.RowDefinitions>
                                        <RowDefinition Height="1*"/>
                                        <RowDefinition Height="1*"/>
                                        <RowDefinition Height="1*"/>
                                        <RowDefinition Height="1*"/>
                                        <RowDefinition Height="1*"/>
                                    </Grid.RowDefinitions>
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="100"/>
                                        <ColumnDefinition Width="*"/>
                                    </Grid.ColumnDefinitions>
                                    <Label Grid.Row="0" Grid.Column="0" Content="№" HorizontalAlignment="Left" VerticalAlignment="Center"/>
                                    <TextBox Grid.Row="0" Grid.Column="1" Text="{Binding TrackRecord.INo, Mode=TwoWay}"/>
                                    <Label Grid.Row="1" Grid.Column="0" Content="Дата" HorizontalAlignment="Left" VerticalAlignment="Center"/>
                                    <TextBox Grid.Row="1" Grid.Column="1" Text="{Binding TrackRecord.IDate, Mode=TwoWay}"/>
                                    <Label Grid.Row="2" Grid.Column="0" Content="Кто принес" HorizontalAlignment="Left" VerticalAlignment="Center"/>
                                    <TextBox Grid.Row="2" Grid.Column="1" Text="{Binding TrackRecord.Via, Mode=TwoWay}"/>
                                    <Label Grid.Row="3" Grid.Column="0" Content="Адресат" HorizontalAlignment="Left" VerticalAlignment="Center"/>
                                    <TextBox Grid.Row="3" Grid.Column="1" Text="{Binding TrackRecord.Attn, Mode=TwoWay}"/>
                                    <Label Grid.Row="4" Grid.Column="0" Content="Отправитель" HorizontalAlignment="Left" VerticalAlignment="Center"/>
                                    <TextBox Grid.Row="4" Grid.Column="1" Text="{Binding TrackRecord.Sender, Mode=TwoWay}"/>
                                </Grid>
                            </DockPanel>
                        </GroupBox>
                        <DataGrid x:Name="inGrid"
                              AutoGenerateColumns="False"
                              EnableRowVirtualization="True"
                              ItemsSource="{Binding TrackRecord.IncTrackRecords}" FrozenColumnCount="1" IsReadOnly="True" SelectionMode="Single" CanUserAddRows="False" CanUserDeleteRows="False">
                        <DataGrid.Columns>
                            <DataGridTextColumn Header="№" Binding="{Binding INo}"/>
                            <DataGridTextColumn Header="Дата" Binding="{Binding IDate}"/>
                            <DataGridTextColumn Header="Кто принес" Binding="{Binding Via}"/>
                            <DataGridTextColumn Header="Адресат" Binding="{Binding Attn}"/>
                            <DataGridTextColumn Header="Отправитель" Binding="{Binding Sender}"/>
                        </DataGrid.Columns>
                    </DataGrid>
                    </DockPanel>
                </TabItem.Content>
            </TabItem>
            <TabItem Name="unBox">
                <TabItem.Header>
                    <StackPanel Orientation="Horizontal">
                        <TextBlock Text="Запросы"/>
                    </StackPanel>
                </TabItem.Header>
                <TabItem.Content>
                    <DataGrid x:Name="unGrid"
                              AutoGenerateColumns="False"
                              EnableRowVirtualization="True"
                              ItemsSource="{Binding TrackRecord.IncTrackRecords}" FrozenColumnCount="1">
                        <DataGrid.Columns>
                            <DataGridTextColumn Header="№" Binding="{Binding INo}"/>
                            <DataGridTextColumn Header="Дата" Binding="{Binding IDate}"/>
                            <DataGridTextColumn Header="Отправитель" Binding="{Binding Sender}" Width="200"/>
                            <DataGridTextColumn Header="Клиент" Binding="{Binding Client}"/>
                            <DataGridTextColumn Header="ИНН" Binding="{Binding INN}"/>
                            <DataGridTextColumn Header="Содержание" Binding="{Binding Content}" Width="300"/>
                            <DataGridTextColumn Header="Примечание" Binding="{Binding Notes}"/>
                            <DataGridTextColumn Header="Кому отдали" Binding="{Binding Person}"/>
                            <DataGridTextColumn Header="Адресат" Binding="{Binding Attn}"/>
                            <DataGridTextColumn Header="Вх.дата" Binding="{Binding JDate}"/>
                            <DataGridTextColumn Header="Вх.№" Binding="{Binding JNo}"/>
                            <DataGridTextColumn Header="Тема" Binding="{Binding JSubject}"/>
                        </DataGrid.Columns>
                    </DataGrid>
                </TabItem.Content>
            </TabItem>
            <TabItem Name="jrlBox">
                <TabItem.Header>
                    <StackPanel Orientation="Horizontal">
                        <TextBlock Text="Входящие"/>
                    </StackPanel>
                </TabItem.Header>
                <TabItem.Content>
                    <DataGrid x:Name="jrlGrid"
                              AutoGenerateColumns="False"
                              EnableRowVirtualization="True"
                              ItemsSource="{Binding TrackRecord.JrlTrackRecords}" FrozenColumnCount="2">
                        <DataGrid.Columns>
                            <DataGridTextColumn Header="Вх.дата" Binding="{Binding JDate}"/>
                            <DataGridTextColumn Header="Вх.№" Binding="{Binding JNo}"/>
                            <DataGridTextColumn Header="Отправитель" Binding="{Binding Sender}"/>
                            <DataGridTextColumn Header="Дата док." Binding="{Binding SendDate}"/>
                            <DataGridTextColumn Header="№ док." Binding="{Binding SendNo}"/>
                            <DataGridTextColumn Header="Тема" Binding="{Binding JSubject}"/>
                            <DataGridTextColumn Header="Исполнитель" Binding="{Binding Person}"/>
                            <DataGridTextColumn Header="Срок отв." Binding="{Binding RDate}"/>
                        </DataGrid.Columns>
                    </DataGrid>
                </TabItem.Content>
            </TabItem>
            <TabItem Name="repBox">
                <TabItem.Header>
                    <StackPanel Orientation="Horizontal">
                        <TextBlock Text="Сроки"/>
                    </StackPanel>
                </TabItem.Header>
                <TabItem.Content>
                    <DataGrid x:Name="repGrid"
                              AutoGenerateColumns="False"
                              EnableRowVirtualization="True"
                              ItemsSource="{Binding TrackRecord.RepTrackRecords}" FrozenColumnCount="1">
                        <DataGrid.Columns>
                            <DataGridTextColumn Header="Срок отв." Binding="{Binding RDate}"/>
                            <DataGridTextColumn Header="Исполнитель" Binding="{Binding Person}"/>
                            <DataGridTextColumn Header="Вх.дата" Binding="{Binding JDate}"/>
                            <DataGridTextColumn Header="Вх.№" Binding="{Binding JNo}"/>
                            <DataGridTextColumn Header="Отправитель" Binding="{Binding Sender}"/>
                            <DataGridTextColumn Header="Тема" Binding="{Binding JSubject}"/>
                            <DataGridTextColumn Header="Исх.дата" Binding="{Binding ODate}"/>
                            <DataGridTextColumn Header="Исх.№" Binding="{Binding ONo}"/>
                        </DataGrid.Columns>
                    </DataGrid>
                </TabItem.Content>
            </TabItem>
            <TabItem Name="outBox">
                <TabItem.Header>
                    <StackPanel Orientation="Horizontal">
                        <TextBlock Text="Исходящие"/>
                    </StackPanel>
                </TabItem.Header>
                <TabItem.Content>
                    <DataGrid x:Name="outGrid"
                              AutoGenerateColumns="False"
                              EnableRowVirtualization="True"
                              ItemsSource="{Binding TrackRecord.OutTrackRecords}" FrozenColumnCount="2">
                        <DataGrid.Columns>
                            <DataGridTextColumn Header="Исх.дата" Binding="{Binding ODate}"/>
                            <DataGridTextColumn Header="Исх.№" Binding="{Binding ONo}"/>
                            <DataGridTextColumn Header="Исполнитель" Binding="{Binding Person}"/>
                            <DataGridTextColumn Header="Кому" Binding="{Binding Receiver}"/>
                            <DataGridTextColumn Header="Тема" Binding="{Binding OSubject}"/>
                            <DataGridTextColumn Header="Вх.дата" Binding="{Binding JDate}"/>
                            <DataGridTextColumn Header="Вх.№" Binding="{Binding JNo}"/>
                        </DataGrid.Columns>
                    </DataGrid>
                </TabItem.Content>
            </TabItem>
            <TabItem Name="clientBox">
                <TabItem.Header>
                    <StackPanel Orientation="Horizontal">
                        <TextBlock Text="Клиенты"/>
                    </StackPanel>
                </TabItem.Header>
                <TabItem.Content>
                    <DataGrid x:Name="clientGrid"
                              AutoGenerateColumns="False"
                              EnableRowVirtualization="True"
                              IsReadOnly="True"
                              ItemsSource="{Binding ClientRecord.ClientRecords}" FrozenColumnCount="1" SelectionMode="Single">
                        <DataGrid.DataContext>
                            <vm:ClientViewModel/>
                        </DataGrid.DataContext>
                        <DataGrid.Columns>
                            <DataGridTextColumn Header="ИНН" Binding="{Binding INN}"/>
                            <DataGridTextColumn Header="Наименование" Binding="{Binding Title}"/>
                        </DataGrid.Columns>
                    </DataGrid>
                </TabItem.Content>
            </TabItem>
        </TabControl>
    </Grid>
</Window>
